<%@ include file="/WEB-INF/jsp/includes/include.jsp" %>
<%@ include file="/WEB-INF/jsp/includes/header.jsp" %>
<jsp:useBean id="cons" class="edu.cornell.cubooks.CUBooksConstants" scope="session"/>
<h2>Current Postings:</h2>
<table cellspacing="0" cellpadding="5" border="1">
	<thead>
		<tr>
			<th>NAME</th>
			<th>DESCRIPTION</th>
			<th>PRICE</th>
			<th></th>
			<c:if test="${posting.status eq 0}">
				<th></th>
				<th>EDIT</th>
				<th>DELETE</th>
			</c:if>
		</tr>
	</thead>
	<tbody>
	<c:forEach var="posting" items="${postingList}" varStatus="rowCounter">
        <c:choose>
          <c:when test="${rowCounter.count % 2 == 0}">
            <c:set var="rowStyle" scope="page" value="row1"/>
          </c:when>
          <c:otherwise>
            <c:set var="rowStyle" scope="page" value="row2"/>
          </c:otherwise>
        </c:choose>
		<tr class="${rowStyle}">
			<td><a href="<c:url value="/postings/show/${posting.id}/"/>"><c:out value="${posting.title}" escapeXml="true" /></a></td>
			<td><c:out value="${posting.description}" escapeXml="true" /></td>
			<td>$${posting.price}</td>
			<td><a href="<c:url value="/postings/show/${posting.id}/"/>">show details</a></td>
			<c:if test="${posting.status eq 0}">
				<td><a href="<c:url value="/postings/start/${posting.id}/"/>">start auction</a></td>
				<td><a href="<c:url value="/postings/edit/${posting.id}/"/>">edit</a></td>
				<td><a href="<c:url value="/postings/delete/${posting.id}/"/>">delete</a></td>
			</c:if>
		</tr>
	</c:forEach>
	</tbody>
</table>

[<a href="<c:url value="/postings/add/"/>">add new posting</a>]

<%@ include file="/WEB-INF/jsp/includes/footer.jsp" %>